﻿@model MVC_Store.Models.ViewModels.Pages.PageVM

@{
    ViewBag.Title = "Edit Page";
}

<h2>Edit Page</h2>

@if (TempData["SM"] != null)
{
    <div class="alert alert-success">
        @TempData["SM"]
    </div>
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.Id)

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Slug, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @if (Model.Slug == "home")
                {
                    @Html.EditorFor(model => model.Slug, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                }
                else
                {
                    @Html.EditorFor(model => model.Slug, new { htmlAttributes = new { @class = "form-control" } })
                }


                @Html.ValidationMessageFor(model => model.Slug, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Body, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextAreaFor(model => model.Body, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Body, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.HasSidebar, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.EditorFor(model => model.HasSidebar)
                    @Html.ValidationMessageFor(model => model.HasSidebar, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Edit Page" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to Pages", "Index")
</div>

<!--Скрипт подмены для CKEditor-->
@section Scripts
{
    <script>
        CKEDITOR.replace("Body")
    </script>
}

